import axios from 'axios'

const BASE_URL = 'http://localhost:8080'

const instance = axios.create({
    baseURL: BASE_URL,
    timeout: 10000
})

// 如果有 token 统一带
instance.interceptors.request.use(config => {
    const token = localStorage.getItem('token')
    if (token) config.headers.Authorization = `Bearer ${token}`
    return config
})

instance.interceptors.response.use(res => res.data)

export default instance